home *** CD-ROM | disk | FTP | other *** search
/ Languguage OS 2 / Languguage OS II Version 10-94 (Knowledge Media)(1994).ISO / gnu / nihcl-30.lha / nihcl-3.0 / lib / SharedQueue.h < prev    next >
C/C++ Source or Header  |  1990-05-19  |  2KB  |  59 lines

  1. #ifndef    SHAREDQUEUE_H
  2. #define    SHAREDQUEUE_H
  3.  
  4. /*$Header: /afs/alw.nih.gov/unix/sun4_40c/usr/local/src/nihcl-3.0/share/lib/RCS/SharedQueue.h,v 3.0 90/05/20 00:21:23 kgorlen Rel $*/
  5.  
  6. /* SharedQueue.h -- declarations for shared queues
  7.  
  8.     THIS SOFTWARE FITS THE DESCRIPTION IN THE U.S. COPYRIGHT ACT OF A
  9.     "UNITED STATES GOVERNMENT WORK".  IT WAS WRITTEN AS A PART OF THE
  10.     AUTHOR'S OFFICIAL DUTIES AS A GOVERNMENT EMPLOYEE.  THIS MEANS IT
  11.     CANNOT BE COPYRIGHTED.  THIS SOFTWARE IS FREELY AVAILABLE TO THE
  12.     PUBLIC FOR USE WITHOUT A COPYRIGHT NOTICE, AND THERE ARE NO
  13.     RESTRICTIONS ON ITS USE, NOW OR SUBSEQUENTLY.
  14.  
  15. Author:
  16.     K. E. Gorlen
  17.     Computer Systems Laboratory, DCRT
  18.     National Institutes of Health
  19.     Bethesda, MD 20892
  20.  
  21. $Log:    SharedQueue.h,v $
  22.  * Revision 3.0  90/05/20  00:21:23  kgorlen
  23.  * Release for 1st edition.
  24.  * 
  25. */
  26.  
  27. #include "ArrayOb.h"
  28. #include "Semaphore.h"
  29.  
  30. class SharedQueue: public VIRTUAL Object {
  31.     DECLARE_MEMBERS(SharedQueue);
  32.     ArrayOb queue;
  33.     int readPosition,writePosition;
  34.     Semaphore valueAvailable;
  35.     Semaphore spaceAvailable;
  36. protected:        // storer() functions for object I/O
  37.     virtual void storer(OIOofd&) const;
  38.     virtual void storer(OIOout&) const;
  39. public:
  40.     SharedQueue(unsigned queueSize =Collection::DEFAULT_CAPACITY);
  41.     SharedQueue(const SharedQueue&);
  42.     bool isFull() const    { return spaceAvailable.value() == 0; }
  43.     virtual unsigned capacity() const;
  44.     virtual Object* copy() const;    // deepCopy()
  45.     virtual void deepenShallowCopy();
  46.     virtual void dumpOn(ostream& strm =cerr) const;
  47.     virtual unsigned hash() const;
  48.     virtual bool isEmpty() const;
  49.     virtual bool isEqual(const Object&) const;
  50.     virtual Object* next();
  51.     virtual Object* nextPut(Object&);
  52.     virtual void printOn(ostream& strm =cout) const;
  53.     virtual unsigned size() const;
  54. private:                // shouldNotImplement()
  55.     virtual int compare(const Object&) const;
  56. };
  57.  
  58. #endif
  59.